package plochki;

//Collision Cell based algorithm
//Same as BaiGrozdan, but Collisions are traversed first even indexes, then odd indexes
public class BaiTupan extends BaiGrozdan {

	public BaiTupan(String inputFile) {
		super(inputFile);
		
		this.name = "BaiTupan";
	}
	
	public BaiTupan(String[] inputFigures) {
		super(inputFigures);
		
		this.name = "BaiTupan";
	}

	//For each Collision, find new places for the Figures in the Collision, starting from the easiest to move
	protected void resolveCollisions() {
		CollisionCell cCell;
		int size = this.collisionCells.size();
		
		//Check first the even indexes
		for (int i = 0; i < size; i+=2) {
			cCell = this.collisionCells.get(i);
			
			//Remove a Figure until a Collision is resolved
			this.resolveCollision(cCell);
		}
		
		//Check the odd indexes
		for (int i = 1; i < size; i+=2) {
			cCell = this.collisionCells.get(i);
			
			//Remove a Figure until a Collision is resolved
			this.resolveCollision(cCell);
		}
	}
}
